<template>
  <div>
    11
    <div id="main" style="height:4rem;"></div>
    <div id="main2" style="height:4rem;"></div>
    <div id="main3" style="height:4rem;"></div>
  </div>
</template>
<script>
import echarts from 'echarts'
console.log(echarts)
export default {
    
    mounted(){
        let instance = echarts.init(document.getElementById('main'));
       var option = {
    title: {
        text: 'ECharts 入门示例'
    },
    tooltip: {},
    legend: {
        data:['销量']
    },
    xAxis: {
        data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
    },
    yAxis: {},
    series: [{
        name: '销量',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20]
    }]
};
        instance.setOption(option);


        let pie= echarts.init(document.getElementById('main2'),'dark');
       var option2 = {
    series : [
        {
            name: '访问来源',
            type: 'pie',
               roseType: 'angle',
            radius: '25%',
            data:[
                {value:235, name:'视频广告'},
                {value:274, name:'联盟广告'},
                {value:310, name:'邮件营销'},
                {value:335, name:'直接访问'},
                {value:400, name:'搜索引擎'}
            ]
        }
    ]

};
       pie.setOption(option2)
       //异步请求
         let async = echarts.init(document.getElementById('main3'));
         //先显示空坐标系
async.setOption({
    title: {
        text: '异步数据加载示例'
    },
    tooltip: {},
    legend: {
        data:['销量']
    },
    xAxis: {
        data: []
    },
    yAxis: {},
    series: [{
        name: '销量',
        type: 'bar',
        data: []
    }]
});

         setTimeout(()=>{
       var option3 = {
    title: {
        text: 'ECharts 入门示例'
    },
    tooltip: {},
    legend: {
        data:['销量']
    },
    xAxis: {
        data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
    },
    yAxis: {},
    series: [{
        name: '销量',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20]
    }]
}
async.setOption(option3);},2000)
        
    }
}
</script>
<style scoped>
</style>